<?php

namespace App\Http\Controllers\Shop;

use App\Shop;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;


class AuthController extends Controller
{
  use AuthenticatesAndRegistersUsers, ThrottlesLogins;

  protected $redirectTo = '/shop';
  protected $guard = 'shop';
  protected $loginView = 'shop.login';
  protected $registerView = 'shop.register';

  public function __construct()
  {
      $this->middleware('guest:shop', ['except' => 'logout']);
  }

  protected function validator(array $data)
  {

      return Validator::make($data, [
          'name' => 'required|max:255',
          'email' => 'required|email|max:255|unique:admins',
          'password' => 'required|confirmed|min:6',
      ]);

  }

  protected function create(array $data)
  {
      return Admin::create([
          'name' => $data['name'],
          'email' => $data['email'],
          'password' => bcrypt($data['password']),
      ]);

  }

}
